$OpenBSD: patch-src_scripting_lua_core_c,v 1.3 2013/10/10 20:08:39 edd Exp $
--- src/scripting/lua/core.c.orig	Sat Aug 22 12:15:08 2009
+++ src/scripting/lua/core.c	Tue Oct  8 23:28:54 2013
@@ -645,7 +645,7 @@ do_hooks_file(LS, unsigned char *prefix, unsigned char
 	if (file_can_read(file)) {
 		int oldtop = lua_gettop(S);
 
-		if (lua_dofile(S, file) != 0)
+		if (luaL_dofile(S, file) != 0)
 			sleep(3); /* Let some time to see error messages. */
 		lua_settop(S, oldtop);
 	}
@@ -656,13 +656,24 @@ do_hooks_file(LS, unsigned char *prefix, unsigned char
 void
 init_lua(struct module *module)
 {
+	static const luaL_Reg lualibs[] = {
+		{"", luaopen_base},
+		{LUA_TABLIBNAME, luaopen_table},
+		{LUA_IOLIBNAME, luaopen_io},
+		{LUA_OSLIBNAME, luaopen_os},
+		{LUA_STRLIBNAME, luaopen_string},
+		{LUA_MATHLIBNAME, luaopen_math},
+		{NULL, NULL}
+	};
+	const luaL_Reg *lib = lualibs;
+
 	L = lua_open();
 
-	luaopen_base(L);
-	luaopen_table(L);
-	luaopen_io(L);
-	luaopen_string(L);
-	luaopen_math(L);
+	for (; lib->func; lib++) {
+		lua_pushcfunction(L, lib->func);
+		lua_pushstring(L, lib->name);
+		lua_call(L, 1, 0);
+	}
 
 	lua_register(L, LUA_ALERT, l_alert);
 	lua_register(L, "current_url", l_current_url);
@@ -767,7 +778,7 @@ handle_ret_eval(struct session *ses)
 		int oldtop = lua_gettop(L);
 
 		if (prepare_lua(ses) == 0) {
-			lua_dostring(L, expr);
+			luaL_dostring(L, expr);
 			lua_settop(L, oldtop);
 			finish_lua();
 		}
